﻿@inherits BaseComponent

<div class="kui-list-box">
    @if (ShowSearch)
    {
        <div class="kui-list-box-search">
            <Search Value="@searchKey" Placeholder="@Language["Tip.EnterKeyword"]" OnSearch="OnSearch" />
        </div>
    }
    <ul class="kui-list-box-body" style="@(ShowSearch ? $"top:32px" : "")">
        @if (items != null && items.Count > 0)
        {
            if (string.IsNullOrWhiteSpace(curItem))
                curItem = items[0].Code;

            foreach (var item in items)
            {
                <li class="@(item.Code == curItem ? "active" : "")" @onclick="e=>OnClick(item)">
                    @if (ItemTemplate != null)
                    {
                        @ItemTemplate(item)
                    }
                    else
                    {
                        @item.Name
                    }
                </li>
            }
        }
        else
        {
            <Empty>
                @if (OnAddClick.HasDelegate)
                {
                    <KButton Type="ButtonType.Primary" Name="添加数据" OnClick="OnAddClick" />
                }
            </Empty>
        }
    </ul>
</div>